#!/bin/bash

cd /tmp
if [ ! -f mongo-1.6.13.tgz ]; then
  iMsg "开始下载安装包"
  wget http://pecl.php.net/get/mongo-1.6.13.tgz
  if [ $? -ne 0 ]; then
    eMsg "mongo ext下载失败，请检查下载地址是否有效！"  
    exit
  fi
fi

iMsg "正在解压文件"
sleep 2
tar zxvf mongo-1.6.13.tgz
cd ./mongo-1.6.13

iMsg "开始安装mongo扩展"
sudo phpize
sudo ./configure
sudo make && sudo make install

#add mongo.so to php.ini
cd /usr/local/php/lib
sudo sed '/extension=php_xsl.dll/a\extension=mongo.so' php.ini > php.ini.tmp
sudo cat php.ini.tmp > php.ini
sudo rm -f *.tmp

sMsg "恭喜，mongo扩展已安装成功"
